﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _4_8
{
    public partial class Form1 : Form
    {
        // 在所有事件处理程序外部声明窗体对象
        Form2 f2 = new Form2();
        Form3 f3 = new Form3();
        Form4 f4 = new Form4();
        Form5 f5 = new Form5();
        Form6 f6 = new Form6();
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // 设置窗体标题
            this.Text = "多重窗体应用程序演示";

            // 设置工具栏按钮文本
            toolStripButton1.Text = "程序1";
            toolStripButton2.Text = "程序2";
            toolStripButton3.Text = "程序3";
            toolStripButton4.Text = "程序4";

            // 设置快捷菜单
            pictureBox1.ContextMenuStrip = contextMenuStrip1;
        }

        // ========== 菜单项点击事件 ==========

        // "程序"菜单下的选项
        private void 程序1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            f2.ShowDialog();
        }

        private void 程序2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            f3.ShowDialog();
        }

        private void 程序3ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            f4.ShowDialog();
        }

        private void 程序4ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            f5.ShowDialog();
        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        // "帮助"菜单下的选项
        private void 关于AToolStripMenuItem_Click(object sender, EventArgs e)
        {
            f6.ShowDialog();
        }

        // ========== 工具栏按钮点击事件 ==========

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            f2.ShowDialog();
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            f3.ShowDialog();
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            f4.ShowDialog();
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            f5.ShowDialog();
        }

        // ========== 快捷菜单事件 ==========

        private void 关于本程序ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            f6.ShowDialog();
        }
    }
}
